<style lang="less" scoped rel="stylesheet/less" type="text/less" >

</style>

<template>
	<div class="customer-product-edit">
		<Form
			ref="form"
			:model="form"
			:label-width="80"
			name="customer_product__form">
			<FormItem
				:label="$t('product.priority')"
				prop="priority">
				<InputNumber
					:max="99999"
					:min="0"
					v-model="form.priority"
					name="customer_product_edit__priority"/>
			</FormItem>
			<FormItem
				:label="$t('product.is_sale')"
				prop="is_sale">
				<i-switch
					:true-value="1"
					:false-value="0"
					v-model="form.is_sale"
					name="customer_product_edit__is_deleted">
					<span slot="open">{{ $t('product.yes') }}</span>
					<span slot="close">{{ $t('product.no') }}</span>
				</i-switch>
			</FormItem>

			<FormItem>
				<Button
					type="primary"
					name="customer_product_edit__submit"
					@click="handleUpdate">
					{{ $t('common.update') }}
				</Button>
			</FormItem>
		</Form>
	</div>
</template>

<script>
export default {
	name: 'CustomerProductEdit',
	props: {
		defaultForm: {
			type: Object,
			required: true,
		},
	},
	data() {
		return {
			form: {
				is_sale: this.defaultForm.is_sale || 0,
				priority: this.defaultForm.priority || 0,
				product_id: this.defaultForm.product_id,
			},
		};
	},
	methods: {
		/**
		 * 更新表单
		 * @return {undefined}
		 */
		handleUpdate() {
			this.$emit('update', this.form);
		},
	},
};
</script>
